from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import declarative_base
from .config import UNKNOWNTYPEID

# 创建基类
Base = declarative_base()

class Uuid(Base):
    __tablename__ = "uuids"
    EntryId = Column(String,primary_key=True)
    Type = Column(Integer,default=UNKNOWNTYPEID)
    TiHash = Column(String,nullable=False)
    Refs = Column(String,default=None)


class Lancer(Base):
    __tablename__ = "lansers"
    EntryId = Column(String,primary_key=True)
    Title = Column(String,nullable=False)
    Authors = Column(String,default="")
    SiteUrl = Column(String,default=None)
    PageUrl = Column(String,default=None)
    Comment = Column(String,default="")
    Summary = Column(String,default="")
    PrimaryCategory = Column(String,default="")
    Categories = Column(String,default="")
    RawJson = Column(String,default="{}")


class Tag(Base):
    __tablename__ = "tags"
    EntryId = Column(String,primary_key=True)
    Key = Column(String,primary_key=True)
    Value = Column(String,default="")


